Repository navigation
Match Node 26 crypto error contracts - #219
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
node-26-target); no dependency on other repair draftsDecipheriv#finalreports a missing or mismatched AEAD tag (GCM, OCB, CCM, ChaCha20-Poly1305) the way Node 26.13.1 does:Error: Unsupported state or unable to authenticate datawithout acode. The 22.14.0 test matched/ auth/, which the old message also satisfied; 26.13.1 asserts the exact message from top-level code, so all 16test-crypto-authenticatedcases failedKeyObject#exportandgenerateKeyPairshare one parser that mirrors Node'sparseKeyEncoding:formatandtypeare required; an invalidformatortypethrowsERR_INVALID_ARG_VALUE;pkcs1/sec1on the wrong key type throwsERR_CRYPTO_INCOMPATIBLE_KEY_OPTIONS;cipher/passphraseare checked, public keys ignore them, and unknown ciphers throwERR_CRYPTO_UNKNOWN_CIPHER;createPrivateKeynames its input optionkey.type(Node 26)util.isDeepStrictEqualpasses explicit DER options when it exports keys to compare themraw-public,raw-private,raw-seed) are unchanged and still unsupportedcrypto.getRandomValuesthrows WebIDLTypeErrors for a missing argument (ERR_MISSING_ARGS) or a non-ArrayBufferView(ERR_INVALID_ARG_TYPE), and uses Node'sTypeMismatchError/QuotaExceededErrormessages;encrypt/decryptcheck the key algorithm before its usages; usage failures sayUnable to use this key to <operation>and algorithm mismatches sayKey algorithm mismatch(sign,verify,wrapKey,unwrapKeyuse the same usage message);length(HmacImportParams.length cannot be 0) and usages (Unsupported key usage for HMAC key) before the key length;alg(HS1–HS512, none for SHA-3), and import rejects a mismatchedalg;DataError/SyntaxErrorfailures areDOMExceptions with codes 0/12, as in Node, not plainErrorsweb_crypto_litegetRandomValues(builds withoutcrypto-full) is unchangedauthTagLength, GCMsetAuthTagaccepts only a 16-byte tag (Node 26 removed implicit short tags, DEP0182); an explicitauthTagLengthstill allows 4, 8 and 12–16;hkdf/hkdfSyncread theinfoview's intrinsic byte range, so a user-definedbyteLengthcannot bypass the 1024-byte limit;ERR_INVALID_ARG_VALUEThe argument 'outputEncoding' cannot be changed from '<encoding>';generateKeyPairrejects unsupported key types (Ed25519,toString, …) synchronously, asgenerateKeyPairSyncalready didNode compatibility
Restored to their 22.14.0 classification and removed from the record's
baselineGaps(343 → 307):test-crypto-authenticatedentries;block_13carries 22.14.0block_12test-webcrypto-encrypt-decrypt(3),test-webcrypto-encrypt-decrypt-aes(3),test-webcrypto-export-import(5) andtest-webcrypto-random(3)test-crypto-gcm-implicit-short-tag,test-crypto-hkdf,test-crypto-encoding-validation-error(2),test-crypto-keygen-eddsaandtest-crypto-keygenblock_01test-webcrypto-randomblock_02stays a recorded gap: it now fails only because the Node 26QuotaExceededErrorglobal is not implemented.Evidence
node_compatcrypto/WebCrypto filter at 5ef6e6e: 180 passed, 0 failed, 406 ignored (164 before, plus the 16 restored); at 950b9c0: 194 passed, 0 failed, 392 ignored--include-ignoredbefore the AEAD restore: the 16test-crypto-authenticatedcases passed, 66 still failed; WebCrypto files with--include-ignoredbefore the WebCrypto restore: the 14 restored cases passed,test-webcrypto-randomblock_02failed as abovecrypto::crypto_error_contracts, with 16 expected lines taken from Node 26.13.1, fails on Switch node_compat to Node 26.13.1 #218's runtime (14 lines differ) and passes herecrypto::webcrypto_error_contracts, with 16 expected lines taken from Node 26.13.1, fails with 5ef6e6e'sweb-crypto.js(14 lines differ) and passes here;crypto::runtime module: 41 passedOn 2256afc:
--include-ignoredbefore the restore;node_compatcrypto/WebCrypto filter: 200 passed, 0 failed, 386 ignoredcrypto::crypto_error_contractsnow has 22 expected lines from Node 26.13.1; with 950b9c0'sweb-crypto.js5 lines differ (the sixth new line is a positive control), and it passes here;crypto::runtime module: 41 passednode_compat_report(36), DTS (87),migrate_config_split(38),cargo fmt --check,cargo clippy --test runtime -- -Dwarningsnode_compat_report(36) andmigrate_config_split(38) tests,cargo fmt --check,cargo clippy --test runtime -- -Dwarningsnode_compatlane, other runtime groups,cargo build/clippy --all-targets(disk headroom); CI not requestedTODO: the remaining 46 crypto/WebCrypto gaps; the 4
test-crypto-cipheriv-decipherivblocks fail in top-leveltestSm4Xts, which needs the new Node 26xtsStandardcipher option; 38 of them are blocked by new Node 26 APIs in top-level test code (raw key formats intest-crypto-key-objectsandtest-crypto-sign-verify, callbackdiffieHellmanintest-crypto-dh-stateless); the native encrypted export ignores the cipher name for PKCS#8; a secondCipheriv#finalreportsERR_CRYPTO_HASH_FINALIZEDinstead ofERR_CRYPTO_INVALID_STATE1e529ff and 198a339
matchedByPositionaudit fix 85600f7; it changes onlytests/migrate_config_split.rssign()/verify()with a callback now validate options and parse the key synchronously and deliver errors of the signing job itself (RSA key too small for the digest, x25519 key) to the callback, as Node does. Restorestest-crypto-async-sign-verifyblock_01 and block_02 (305 baseline gaps, 44 crypto/WebCrypto gaps)DiffieHellman#computeSecretrejects a peer key of p - 1 and reports both limits asRangeErrorERR_CRYPTO_INVALID_KEYLEN, as Node doescrypto::crypto_error_contractshas 6 more lines, all 28 equal to the host Node 26.13.1 output, and passes. node_compat in CI mode: async-sign-verify and DH files 18 passed, 9 ignored; with--include-ignored, the crypto/WebCrypto filter has no runnable regression (one--expose-internalstest is ignored by the harness). Report regenerated, fmt cleanverifyErrorstill follows neither OpenSSL generation, because the harness shim'shasOpenSSL()is always false (OpenSSL 1.1 test branches) and generated DH primes are not safe primes.test-crypto-dh-curvesstays a gape0772f3 (review fixes)
sign()/verify()with a callback check the key type before the job, also for a bare or nested KeyObject: a public or secret key forsignand a secret key forverifythrowERR_CRYPTO_INVALID_KEY_OBJECT_TYPEsynchronously and never reach the callback, as in Node 26padding/saltLengthvalues read during validation, so inherited and non-enumerable options are kept (they were dropped by an object spread)crypto::crypto_error_contractshas 9 more lines (37, all equal to the host Node 26.13.1 output): with 198a339'sweb-crypto.jsexactly the 6 new key-type/option lines fail and the 3 controls pass; on e0772f3 it passes, and thecrypto::runtime module passes (41)--include-ignored: 587 results identical to the 198a339 tree, no runnable regression (the--expose-internalstest the harness ignores still fails on its internal require);node_compat_config_report_is_currentpassesOn 454e7f7 (merge of node-26-target at 57656e1, which brings in #216's explicit mapping decisions):
git diff 57656e13 454e7f71equalsgit diff 1359ce9c e0772f33, so the crypto change is unchanged.migrate_config_split ':tag:migration_contract'24/24, clippy-Dwarningson that target andnode_compat_config_report_is_currentpass. The crypto node_compat cases were not rerun for the merge.